<template> 
<!-- 表单筛选组件 -->
  <div style="margin-left: 4px;">
    <i class="icon" v-if="item.filters" @click="showFilter = !showFilter"
      :class="[showFilter ? 'el-icon-arrow-up' : 'el-icon-arrow-down']"></i>
    <div v-if="showFilter && item.filters" class="filter">
      <div class="filterContainer">
        <i @click="showFilter = false" class="el-icon-close close"></i>
        <el-checkbox-group v-model="checkList">
          <div v-for="i in item.filters" :key="i.value">
            <el-checkbox :label="i.value">{{ i.text }}</el-checkbox>
          </div>
        </el-checkbox-group>
        <div style="display: block;">
          <el-button @click="onReset">清空</el-button>
          <el-button type="primary" @click="handleFilter">确定</el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "uiFilter",
  props: {
    item: {
      type: Object,
      default: () => { return {} }
    },
  },
  data() {
    return {
      showFilter: false,
      checkList: []
    }
  },
  created() {
  },
  methods: {
    onReset() {
      this.checkList = []
    },
    handleFilter() {
      this.showFilter = false
      this.$emit('handleFilter', { key: this.item.key, value: this.checkList })
    }
  }
}
</script>
<style scoped lang="less">
.filter {
  position: absolute;
  top: 24px;
  left: 0px;
  min-height: 52px;
  box-shadow: -2px 2px 5px -4px #000;
  background-color: #fff;
  border-radius: 5px;
  min-width: 120px;
  border: .5px solid #d8a764;

  .filterContainer {
    position: relative;
    padding: 8px 10px;
    .close {
      position: absolute;
      right: 8px;
      cursor: pointer;
    }
  }
}

.icon {
  cursor: pointer;
}



:deep(.el-button) {
  margin-top: 12px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  padding: 0 7px;
  font-size: 9px;
  border-radius: 3px;
}

:deep(.el-button--default) {
  color: #d8a764;
  background-color: #fff;
  border-color: #d8a764;
}

:deep(.el-button--default) {
  color: #d8a764;
  background-color: #fff;
  border-color: #d8a764;
}

:deep(.el-button--primary) {
  background-color: #d8a764;
  border-color: #d8a764;
}
</style>